<?php

session_start();
include_once '../conf/conf.php';
$pid = $_SESSION['pid'];
$sex = $_SESSION['sex']; if ($sex == 'M'){$bg = '../img/chrt1.jpg';} if ($sex == 'F'){$bg = '../img/chrt2.jpg';}
$dob = $_SESSION['dob'];
$x0 = strtotime($dob);
$x1 = $x0 + (86400*1826);
      $sql = "SELECT gid, wthtd, wt, ht FROM wtht WHERE pid = '$pid' ORDER BY wthtd DESC";
      $res = mysqli_query($con, $sql) or die("sorry, database is updating...");
$htdata = array();
$wtdata = array();
while ($row = mysqli_fetch_array($res)) {
  extract($row);
  $f_date = strtotime($wthtd);
  if ($ht == 0){$ht = '';}
  if ($wt == 0){$wt = '';}
  $htdata[] = array('', $f_date, $ht);
  $wtdata[] = array('', $f_date, $wt);  
}
mysqli_free_result($res);
mysqli_close($con);

include('phplot.php');

$kit = new PHPlot(800, 1200, NULL, $bg);
$kit->SetFileFormat('jpg');

$kit->SetPrintImage(0);

$kit->SetPlotAreaPixels(50,9,726,860);
$kit->SetPlotAreaWorld($x0, 40, $x1, 120);
$kit->SetDataValues($htdata);

$kit->SetPlotType('linepoints');
$kit->SetDataType('data-data');
$kit->SetDataColors(array('blue'));
$kit->SetPointSizes(10);
$kit->SetLineWidth(2);

$kit->SetDrawXAxis(FALSE);
$kit->SetDrawYAxis(FALSE);
$kit->SetXDataLabelPos('none');
$kit->SetYDataLabelPos('none');
$kit->SetDrawXGrid(FALSE);
$kit->SetDrawYGrid(FALSE);
$kit->SetXTickPos('none');
$kit->SetXTickLabelPos('none');
$kit->SetYTickPos('none');
$kit->SetYTickLabelPos('none');
$kit->DrawGraph(); 

$kit->SetPlotAreaPixels(50,433,726,1072);
$kit->SetPlotAreaWorld($x0, 0, $x1, 30);
$kit->SetDataValues($wtdata);
$kit->DrawGraph();
$kit->PrintImage();
?>